//
// Copyright (c) 2024 BPer
//

#include <bperrtp/BPerRtcpBye.h>
#include <bperutil/sys/BPerLog.h>

void bPer_create_rtcpBye(BPerRtcpCommon* comm){
	comm->ssrc = 0;
	comm->header.padding = 0;
	comm->header.type = BPerRtcpType_bye;
	comm->header.rc = 0;
	comm->header.version = kRtcpVersion;
}
void bPer_destroy_rtcpBye(BPerRtcpCommon* comm){

}
int32_t bPer_encode_rtcpBye(BPerRtcpCommon* comm,BPerBuffer* buffer){
	int32_t err = BPer_Ok;

	if(BPer_Ok != (err = bPer_encode_header_rtcpCommon(comm,buffer))) {
		return bPer_error_wrap(err, "encode header");
	}
	return err;
}
int32_t bPer_decode_rtcpBye(BPerRtcpCommon* comm,BPerBuffer* buffer){

	int32_t err = BPer_Ok;
	comm->data = buffer->head;
	comm->nb_data = bPer_buffer_left(buffer);//->left();

	if(BPer_Ok != (err = bPer_decode_header_rtcpCommon(comm,buffer))) {
		return bPer_error_wrap(err, "decode header");
	}
	return err;
}
